Micron Document
🎖️GitЯра🎖️

Node / meshtastic / Meshtastic-Android / files / core / ui / src / commonTest / kotlin / org / meshtastic / core / ui / emoji / EmojiCellSizeTest.kt

Displaying Raw • Download

core/ui/src/commonTest/kotlin/org/meshtastic/core/ui/emoji/EmojiCellSizeTest.kt b4bedd92fcc8d65daff79200d71f6ebc3d8f0cfa (b4bedd92) Text, 2.15 KB

T8b949e/*
* Copyright (c) 2026 Meshtastic LLC
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
Tff7b72package T7ee787org.meshtastic.core.ui.emoji

Tff7b72import T7ee787androidx.compose.ui.unit.dp
Tff7b72import T7ee787kotlin.test.Test
Tff7b72import T7ee787kotlin.test.assertEquals
Tff7b72import T7ee787kotlin.test.assertTrue

T8b949e/**
* Guards the emoji-picker grid against clipping its glyphs at large system font scales (meshtastic/design#86).
*
* The picker's own rendering is not asserted here: color emoji glyphs come from the host's emoji font, so a screenshot
* golden of them is not reproducible between a dev machine and CI. The sizing rule is, so that is what is pinned.
*/
Tff7b72class T56d364EmojiCellSizeTest Tb4b4b4{

T8b949e/** 24.sp emoji at the font scales Android exposes, in dp. */
Tff7b72private Tff7b72val Te6edf3glyphAtScale Tff7b72= Te6edf3mapOfTb4b4b4(T79c0ff1.0f Te6edf3to T79c0ff2T79c0ff4.Te6edf3dpTb4b4b4, T79c0ff1.15f Te6edf3to T79c0ff2T79c0ff7.6Tb4b4b4.Te6edf3dpTb4b4b4, T79c0ff1.3f Te6edf3to T79c0ff3T79c0ff1.2Tb4b4b4.Te6edf3dpTb4b4b4, T79c0ff1.5f Te6edf3to T79c0ff3T79c0ff6.Te6edf3dpTb4b4b4, T79c0ff2.0f Te6edf3to T79c0ff4T79c0ff8.Te6edf3dpTb4b4b4)

Tf0883e@Test
Tff7b72fun Td2a8ff`cell always fits the glyph`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3glyphAtScaleTb4b4b4.Te6edf3forEach Tb4b4b4{ Tb4b4b4(Te6edf3scaleTb4b4b4, Te6edf3glyphTb4b4b4) Tff7b72-Tff7b72>
Tff7b72val Te6edf3cell Tff7b72= Te6edf3emojiCellSizeForTb4b4b4(Te6edf3glyphTb4b4b4)
Te6edf3assertTrueTb4b4b4(Te6edf3cell Tff7b72>Tff7b72= Te6edf3glyphTb4b4b4, Ta5d6ff"Ta5d6ffat fontScale Tffd700$Te6edf3scaleTa5d6ff a Tffd700$Te6edf3glyphTa5d6ff glyph would be clipped by a Tffd700$Te6edf3cellTa5d6ff cellTa5d6ff"Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`cell never drops below the minimum touch target`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3glyphAtScaleTb4b4b4.Te6edf3valuesTb4b4b4.Te6edf3forEach Tb4b4b4{ Te6edf3glyph Tff7b72-Tff7b72> Te6edf3assertTrueTb4b4b4(Te6edf3emojiCellSizeForTb4b4b4(Te6edf3glyphTb4b4b4) Tff7b72>Tff7b72= T79c0ff4T79c0ff4.Te6edf3dpTb4b4b4) Tb4b4b4}
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`default font scale keeps the original cell size`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertEqualsTb4b4b4(T79c0ff4T79c0ff4.Te6edf3dpTb4b4b4, Te6edf3emojiCellSizeForTb4b4b4(T79c0ff2T79c0ff4.Te6edf3dpTb4b4b4)Tb4b4b4)
Tb4b4b4}

Tf0883e@Test
Tff7b72fun Td2a8ff`cell grows once the glyph outgrows the minimum`Tb4b4b4(Tb4b4b4) Tb4b4b4{
Te6edf3assertTrueTb4b4b4(Te6edf3emojiCellSizeForTb4b4b4(T79c0ff4T79c0ff8.Te6edf3dpTb4b4b4) Tff7b72> Te6edf3emojiCellSizeForTb4b4b4(T79c0ff2T79c0ff4.Te6edf3dpTb4b4b4)Tb4b4b4)
Tb4b4b4}
Tb4b4b4}

Served by rngit 1.5.0 - Generated in 0.06s